package br.com.ss.seguranca.model.dao;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import br.com.ss.seguranca.model.entity.Status;

@Component
public class StatusDAO {

	@PersistenceContext
	private EntityManager entityManager;

	@Transactional
	public void save(Status sistema) {
		entityManager.persist(sistema);
	}

	@Transactional
	public void merge(Status sistema) {
		entityManager.merge(sistema);
	}

	@Transactional
	public void remove(Status sistema) {
		Status entity = entityManager.merge(sistema);
		entityManager.remove(entity);
	}

	@SuppressWarnings("unchecked")
	public List<Status> list() {
		return entityManager.createQuery("select t from Status t")
				.getResultList();
	}

}
